1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*!
`isotope` errors
*/
use crate::value::{Linearity, Relationship, Dependency, Usage};
use failure_derive::Fail;

/// `isotope` errors
#[derive(Debug, Copy, Clone, Fail, Eq, PartialEq, Hash)]
pub enum Error {
    /// An undefined symbol
    #[fail(display = "Undefined symbol")]
    UndefinedSymbol,
    /// An identifier is defined, but not a symbol
    #[fail(display = "Identifier does not refer to a symbol")]
    NotASymbol,
    /// A value is not a valid type
    #[fail(display = "Value is not a type")]
    NotAType,
    /// A value is not a valid instant
    #[fail(display = "Value is not an instant")]
    NotAnInstant,
    /// A value is not a valid function
    #[fail(display = "Value is not a function")]
    NotAFunction,
    /// A value is not a valid function type
    #[fail(display = "Value is not a function type")]
    NotAFunctionType,
    /// A malformed parameter declaration
    #[fail(display = "Malformed parameter declaration")]
    MalformedParam,
    /// A type mismatch
    #[fail(display = "Type mismatch")]
    TypeMismatch,
    /// Variance needs to be covariant
    #[fail(display = "Variance needs to be covariant")]
    NeedsCovar,
    /// Variance needs to be contravariant
    #[fail(display = "Variance needs to be contravariant")]
    NeedsContravar,
    /// A mismatch of universe levels
    #[fail(display = "Universe level mismatch")]
    UniverseLevelMismatch,
    /// A contradictory constraint set where not expected
    #[fail(display = "Unexpected contradictory constraint-set")]
    Contradiction,
    /// A cycle causing a contradiction
    #[fail(display = "Instant order cycle")]
    Cycle,
    /// An affine value is used twice
    #[fail(display = "An affine value is used twice, i.e. a double-use error")]
    DoubleUse(Usage, Usage),
    /// Incompatible type linearities
    #[fail(display = "Incompatible type linearities {:?} and {:?}", 0, 1)]
    IncompatibleTypeLinearity(Linearity, Linearity),
    /// Incompatible call linearities
    #[fail(display = "Incompatible call usages {:?} and {:?}", 0, 1)]
    IncompatibleCallUsage(Usage, Usage),
    /// Type linearity too weak
    #[fail(display = "Type linearity too weak: !({:?} <= {:?})", 0, 1)]
    TypeLinearityTooWeak(Linearity, Usage),
    /// Incompatible linearities
    #[fail(display = "Incompatible linearities {:?}", 0)]
    IncompatibleLinearity(Option<(Linearity, Linearity)>),
    /// Wrong linearity ordering
    #[fail(display = "Wrong linearity ordering")]
    WrongLinearityOrder,
    /// Incompatible symbol dependencies
    #[fail(display = "Incompatible symbol dependencies {:?} and {:?}", 0, 1)]
    IncompatibleDependencies(Dependency, Dependency),
    /// Incompatible relationships
    #[fail(display = "Incompatible relationships {:?} and {:?}", 0, 1)]
    IncompatibleRelationships(Relationship, Relationship),
    /// A custom error message
    #[fail(display = "{}", 0)]
    Message(&'static str),
}